package bma.common.langutil.ai.impl;

import bma.common.langutil.ai.stack.AISRun;
import bma.common.langutil.ai.stack.AIStack;
import bma.common.langutil.ai.vm.AIContext;

public class AIServiceTC1 {

	final org.slf4j.Logger log = org.slf4j.LoggerFactory
			.getLogger(AIServiceTC1.class);

	private AIContext context;

	public AIContext getContext() {
		return context;
	}

	public void setContext(AIContext context) {
		this.context = context;
	}

	public boolean say(AIStack<Boolean> stack, final String word) {
		log.info("say ~~ {}", word);
		return stack.success(true);
	}

	public boolean asynSay(AIStack<String> stack, final String name) {
		this.context.execute(new AISRun<String>(stack) {

			@Override
			public void execute() {
				String r = "Dr. " + name;
				log.info("say ~~ {}", r);
				success(r);
			}
		});
		return false;

		// return AIUtil.asynExecute(stack, executor, new AISRun<String>() {
		// @Override
		// public void execute() {
		// String r = "Dr. " + name;
		// log.info("say ~~ {}", r);
		// success(r);
		// }
		// });
	}
}
